import request from "../../../utils/request";
import { SpuInfoResponseForm } from "./type";

enum API {
  reqSpuInfoUrl = "/admin/product/",
  reqSpuInfoByIdUrl = "/admin/product/getSpuInfo/",
  reqUpdateSpuInfoUrl = "/admin/product/updateSpuInfo",
  reqBaseAttrUrl = "/admin/product/baseSaleAttrList",
  reqSaveSpuInfoUrl = "/admin/product/saveSpuInfo",
  reqDelSpuUrl = "/admin/product/deleteSpu/",
}

export const reqSpuInfo = (curPage: number, pageSize: number, c3id: any) => {
  const params = new URLSearchParams({ category3Id: c3id });
  return request.get(API.reqSpuInfoUrl + `${curPage}/${pageSize}`, { params });
};

export const reqSpuInfoById = (spuId: number) =>
  request.get<any, SpuInfoResponseForm>(API.reqSpuInfoByIdUrl + spuId);

export const reqUpdateSpuInfo = (data: any) =>
  request.post(API.reqUpdateSpuInfoUrl, data);
export const reqSaveSpuInfo = (data: any) =>
  request.post(API.reqSaveSpuInfoUrl, data);

export const reqBaseAttr = () => request.get(API.reqBaseAttrUrl);

export const reqDelSpu = (SpuId: number) => request.delete(API.reqDelSpuUrl + SpuId);
